package example.designpattern.singleton;


/**
 * 利用内部类实现单例，拥有懒汉式的优点，也避免了多线程下指令重排的问题
 */
public class Singleton {

  private static class SingletonHolder {

    private static final Singleton INSTANCE = new Singleton();

  }

  private Singleton() {

  }

  public static Singleton getInstance() {

    return SingletonHolder.INSTANCE;
  }

}
